﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NineMine.DataModel.Initialization
{
    public class DatabaseCreator : CreateDatabaseIfNotExists<NineMineDataContext>
    {
     
        protected override void Seed(NineMineDataContext context)
        {
            
            base.Seed(context);

            if (context.Enumerations.Count() == 0)
            {
                context.Enumerations.AddOrUpdate(new List<Enumeration>()
                { 
                    new Enumeration { Id = 1, Name = "Low", Position = 1, IsDefault = false, EnumerationType = "IssuePriority", Active = true, Project = null, Parent = null, PositionName= "lowest"},
                    new Enumeration { Id = 2, Name = "Normal", Position = 2, IsDefault = true, EnumerationType = "IssuePriority", Active = true, Project = null, Parent = null, PositionName= "default"},
                    new Enumeration { Id = 3, Name = "High", Position = 3, IsDefault = false, EnumerationType = "IssuePriority", Active = true, Project = null, Parent = null, PositionName= "high3"},
                    new Enumeration { Id = 4, Name = "Urgent", Position = 4, IsDefault = false, EnumerationType = "IssuePriority", Active = true, Project = null, Parent = null, PositionName= "high2"},
                    new Enumeration { Id = 5, Name = "Immediate", Position = 5, IsDefault = false, EnumerationType = "IssuePriority", Active = true, Project = null, Parent = null, PositionName= "highest"},
                    new Enumeration { Id = 6, Name = "User documentation", Position = 1, IsDefault = false, EnumerationType = "DocumentCategory", Active = true, Project = null, Parent = null, PositionName= null},
                    new Enumeration { Id = 7, Name = "Technical documentation", Position = 2, IsDefault = false, EnumerationType = "DocumentCategory", Active = true, Project = null, Parent = null, PositionName= null},
                    new Enumeration { Id = 8, Name = "Design", Position = 1, IsDefault = false, EnumerationType = "TimeEntryActivity", Active = true, Project = null, Parent = null, PositionName= null},
                    new Enumeration { Id = 9, Name = "Development", Position = 2, IsDefault = false, EnumerationType = "TimeEntryActivity", Active = true, Project = null, Parent = null, PositionName= null}
                }.ToArray());

                context.SaveChanges();
            }
        }
    }
}
